package cn.edu.nhic.nhcarsb.controller.admin;

import cn.edu.nhic.nhcarsb.controller.BaseController;
import cn.edu.nhic.nhcarsb.entity.Admin;
import cn.edu.nhic.nhcarsb.entity.R;
import cn.edu.nhic.nhcarsb.service.AdminService;
import cn.edu.nhic.nhcarsb.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/admin")
public class AdminController extends BaseController {
    @Autowired
    private AdminService adminService;
    @GetMapping("/info")
    public R info(String token){
        Integer aid = JwtUtils.verifyAdminTokenAndGetId(token);
        Admin admin = adminService.getById(aid);
        HashMap<String,String> map = new HashMap<>();
        map.put("name",admin.getAname());
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        return R.success(map);
    }
    @PostMapping("/logout")
    public R logout(){
        return R.success("ok");
    }
}
